
package com.sausageking.shared;

public class BuyerException extends Exception {

  private static final long serialVersionUID = -1006619825240737974L;

  public enum Code {
    INVALID_ORDER_CONFIMRATION_CODE("Invalid confirmation code."),
    AUTH_FAILED("Incorrect PIN."),
    INVALID_EMAIL("Invalid email address."),
    MERCHANT_NOT_FOUND("Invalid merchant."),
    USER_ALREADY_EXISTS("User already signed up."),
    USER_SIGNUP_FAILED("Please come back later."),
    UNKNOWN_USER("User has not signed up."),
    EMPTY_PASSWORD("Empty PIN"),
    STAMP_TOO_OFTEN("Limit one stamp per day."), 
    INVALID_PASSWORD_LENGTH ("PIN needs to be 4-8 characters.");

    private String message;

    Code(String message) {
      this.message = message;
    }

    public String getMessage() {
      return message;
    }
  }

  private Code code;

  public BuyerException() {
    super();
  }

  public BuyerException(Code code) {
    super();
    this.code = code;
  }

  @Override
  public String getMessage() {
    return code.name();
  }

  public Code getCode() {
    return code;
  }
}
